package com.levi.utils;

import android.os.Handler;
import android.os.Looper;

/**
 * Created by Levi on 17/3/8.
 */

public class UiHandler {

    private UiHandler() {

    }

    private static final Handler UI_HANDLER = new Handler(Looper.getMainLooper());

    public static void postOnUiThread(Runnable runnable) {
        synchronized (UI_HANDLER) {
            UI_HANDLER.post(runnable);
        }
    }

    public static void postOnUiThreadDelay(Runnable runnable, long delayTimeInMills) {
        synchronized (UI_HANDLER) {
            UI_HANDLER.postDelayed(runnable, delayTimeInMills);
        }
    }

    public static void removeCallbacks(Runnable runnable) {
        synchronized (UI_HANDLER) {
            UI_HANDLER.removeCallbacks(runnable);
        }
    }
}
